'use strict';

/* Directives */


var NormalCMSDirective = angular.module('NormalCMS.directives', [])
NormalCMSDirective.directive('appVersion', ['version', function (version) {
  return function (scope, elm, attrs) {
    elm.text(version);
  };
}]).directive('pwCheck', function () {
  return {
    require: 'ngModel',
    link: function (scope, elem, attrs, ctrl) {
      var firstPassword = '#' + attrs.pwCheck;
      // 网上好多例子都掉了$(elem) 美元符号和括号  
      $(elem).add(firstPassword).on('keyup', function () {
        scope.$apply(function () {
          alert(elem.val());
          var v = elem.val() === $(firstPassword).val();
          ctrl.$setValidity('pwmatch', v);
        });
      });
    }
  };
});
